<!doctype html>
<html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
%>
<head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="js/libs/modernizr.min.js"></script>
    <jsp:include page="/manage/inc/header"></jsp:include>
</head>
<body>

<!--/sidebar-->
<div class="main-wrap">

            <div class="result-content" id="show">

            </div>
        </form>
    </div>
</div>
<!--/main-->
</div>
</body>
<jsp:include page="/manage/inc/footer"></jsp:include>
<script>

    $(function () {
        initData(1);
    })
    //模糊查询
    $(function () {
        $("#show").on("click","#seek",function () {
            var title = $("#matter").val();
            var action  = "<%=path%>/manage/ajaxJsp/SeachVolunteer";
            $.post(action,{title:title},function (mes) {
                $("#show").html(mes)
            })
        })
    })
    //志愿者申请列表
    $(function () {
        $("#show").on("click","#count",function () {
            var action = "<%=path%>/manage/ajaxJsp/volunteerApply";
            $.post(action,function (mes) {
                $("#show").html(mes)
            })
        })
    })
//志愿者申请通过
    $(function () {
        $("#show").on("click",".pass",function () {
            var id = $(this).data("id")
            layer.confirm("确认通过审核吗",function () {
                var url="<%=path%>/manage/VolunteerPass"
                $.post(url,{id:id},function (mes) {
                    layer.msg("通过完成")
                 $("tr[id=tr"+id+"]").remove();
                })
            })
        })
    })
    function initData(pageNum) {
        var action = "<%=path%>/manage/ajaxJsp/volunteerShow";
        $.post(action,{pageNum:pageNum},function (mes) {
            $("#show").html(mes)
        })

        //注销志愿者
        $.ajaxSettings.async = false;
        $(function () {
            $("#show").on("click",".link-del",function () {
                var id = $(this).data("id")
                layer.confirm("确定要注销吗",function () {
                    var url="<%=path%>/manage/volunteer/delete"
                    $.post(url,{id:id},function (mes) {
                        layer.msg("已经注销")
                        initData(pageNum);
                    })
                })
            })
        })
        //恢复志愿者
        $.ajaxSettings.async = false;
        $(function () {
            $("#show").on("click",".link-dell",function () {
                var id=$(this).data("id");
                layer.confirm("确定要恢复吗",function () {
                    var url = "<%=path%>/manage/recover"
                    $.post(url,{id:id},function () {
                        layer.msg("已经恢复")
                        initData(pageNum);
                    })
                })
            })
        })
    }
    //志愿者申请详情
    $(function () {
        $("#show").on("click",".volunteerApply",function () {
            var id = $(this).data("id");
            //此处用于演示
            layer.open({
                type: 2,
                title: '志愿者信息',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['893px', '600px'],
                content: '<%=path%>/manage/ajaxJsp/volunteerApplyInfo?id='+id
            });
        })
    })
//分页
   $(function () {
       $("#show").on("click",".list",function () {
           var pageNum = $(this).data("id");
          initData(pageNum);
       })
   })
    //申请分页
    $(function () {
        $("#show").on("click",".page",function () {
            var pageNum = $(this).data("id");
            initData(pageNum);
        })
    })
    //搜索分页
    $(function () {
        $("#show").on("click",".seachPage",function () {
            var pageNum = $(this).data("id");
            initData(pageNum);
        })
    })
    //志愿者驳回
    $(function () {
        $("#show").on("click",".reject",function () {
            var id = $(this).data("id")
            layer.prompt({
                formType: 2,
                title: '请输入驳回理由'
            }, function(value, index, elem){
             var action= "<%=path%>/manage/deleteReason";
             var deleteReason = value;
             $.post(action,{deleteReason:deleteReason,id:id},function () {
                 layer.close(index);
                 layer.confirm("确认驳回此申请吗",function () {
                     var url="<%=path%>/manage/volunteerReject"
                     $.post(url,{id:id},function (mes) {
                         layer.msg("申请已驳回")
                         $("tr[id=tr"+id+"]").remove();
                     })
                 })
             })

            });
        })
    })


    //志愿者弹出详情页
    $(function () {
        $("#show").on("click","#name",function () {
            var id = $(this).data("id");
            //此处用于演示
            layer.open({
                type: 2,
                title: '志愿者信息',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['893px', '600px'],
                content: '<%=path%>/manage/ajaxJsp/volunteerShowInfo?id='+id
            });
        })
    })
   
</script>
</html>
